package org.ithasu.uBroadcast.test;

import org.ithasu.uBroadcast.UMessage;
import org.ithasu.uBroadcast.connectors.UDPConnector;

public class TestHello {

	public static void main(String[] args) {
		try {
			UMessage m = new UMessage();
			m.add("Hello world, this is java!");
			m.setType((byte) 0);

			UDPConnector conn = new UDPConnector("j_helo".getBytes(),
					UDPConnector.DEFAULT_PORT, 1000);
			while (true) {
				// if (m != null) {
				// m.debug(System.out);
				// conn.send(m);
				// } else {
				// System.out.println(".");
				// }
				// m = conn.recv();
				m.debug(System.out);
				conn.send(m);
				m.setType((byte) ((m.getType() + 1) % 16));
				try {
					Thread.sleep(1000);
				} catch (Exception e) {
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
